﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace FAMailUtils.MailGun
{
    class MailGunUtils
    {
        public static bool Verify(string apikey, string token, string timestamp, string signature)
        {
            var hmac = new HMACSHA256(Encoding.ASCII.GetBytes(apikey));
            var sigBytes = hmac.ComputeHash(Encoding.ASCII.GetBytes(timestamp + token));
            string sigString = BitConverter.ToString(sigBytes).Replace("-", "");
            return signature.Equals(sigString, StringComparison.OrdinalIgnoreCase);
        }
    }
}
